/**
 * 用户地址模块路由文件
 */

const Router = require('koa-router');
const router = new Router();
const { validate } = require('../validators/common');
const { add, update, deleteAddress, getAll, getPCD } = require('../services/userAddress');
const { validAdd, validUpdate } = require('../validators/userAddress');
const { authorization } = require('./common');

router.prefix('/users_address');

router.post('/add', authorization('usersAddressAdd'), validate(validAdd), add);

router.put('/update', authorization('usersAddressUpdate'), validate(validUpdate), update);

router.get('/all/:id', authorization('usersAddressList'), getAll);

router.delete('/delete/:id', authorization('usersAddressDelete'), deleteAddress);

router.get('/pcd', authorization('usersAddressAdd', 'usersAddressUpdate'), getPCD);

module.exports = router;